package com.beanpostprocessor.parent;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class ParentBeanPostProcessor implements BeanPostProcessor{

	private String name;
	
	public void setName(String name) {
		this.name = name;
	}
	
	
	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		if(bean instanceof Parent){
			((Parent)bean).setParentName(this.name);
		}
		return bean;
	}
}